package com.library.bean;

import java.util.List;

public class Page<T> {
	private List<T> data;//查询到的数据
	private int pageNum;//当前页码
	private int pageSize;//页面大小
	private int totalNum;//总条数
	private int totalPage;//总页数
	private boolean hasPrev;//有上一页
	private boolean hasNext;//有下一页
	public List<T> getData() {
		return data;
	}
	public void setData(List<T> data) {
		this.data = data;
	}
	public int getPageNum() {
		return pageNum;
	}
	public void setPageNum(int pageNum) {
		this.pageNum = pageNum;
	}
	public int getPageSize() {
		return pageSize;
	}
	public void setPageSize(int pageSize) {
		this.pageSize = pageSize;
	}
	public int getTotalNum() {
		return totalNum;
	}
	public void setTotalNum(int totalNum) {
		this.totalNum = totalNum;
	}
	public int getTotalPage() {
		return totalPage;
	}
	public void setTotalPage(int totalPage) {
		this.totalPage = totalPage;
	}
	public boolean isHasPrev() {
		return hasPrev;
	}
	public void setHasPrev(boolean hasPrev) {
		this.hasPrev = hasPrev;
	}
	public boolean isHasNext() {
		return hasNext;
	}
	public void setHasNext(boolean hasNext) {
		this.hasNext = hasNext;
	}
	public Page(List<T> data, int pageNum, int pageSize, int totalNum) {
		this.data = data;
		this.pageNum = pageNum;
		this.pageSize = pageSize;
		this.totalNum = totalNum;
		if(totalNum%pageSize==0) {//算总页数
			this.totalPage = totalNum/pageSize;
		}else {
			this.totalPage = (totalNum/pageSize)+1;
		}
		if(pageNum<=1) {//当前页码小于等于1时，无上一页
			this.hasPrev = false;
		}else {
			this.hasPrev = true;
		}
		if(pageNum>=totalPage) {//当前页面大于等于总页数时，无下一页
			this.hasNext = false;
		}else {
			this.hasNext = true;
		}
	}
}
